//
//  FIViewController.m
//  Magpie
//
//  Created by user on 12-8-31.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "FIViewController.h"

@interface FIViewController ()

@end

@implementation FIViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self loadWebPageWithString:@"http://www.baidu.com"];
	// Do any additional setup after loading the view, typically from a nib.
    loadingView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
    loadingView.center = CGPointMake(150, 50);
    [loadingView setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
    [self.view addSubview:loadingView];
}

- (void)viewDidUnload
{
    [self setSeeWebView:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (void)loadWebPageWithString:(NSString*)urlString
{
    NSURL *url =[NSURL URLWithString:urlString];
    NSLog(@"data:%@", urlString);
    NSURLRequest *request =[NSURLRequest requestWithURL:url];
    [self.SeeWebView loadRequest:request];
}

- (void)doBlock
{
    void (^aBlock)(void) = ^(void){ NSLog(@"Hello, World!"); };
}

- (NSString*)iconImageName
{
    return @"magnifying-glass.png";
}

- (void)dealloc {
    [_SeeWebView release];
    [super dealloc];
}
#pragma mark - (webviewdelegate)
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    return YES;
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [loadingView startAnimating];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
//    [loadingView stopAnimating];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    [loadingView stopAnimating];
}
@end
